#!/usr/bin/python

import sys

art_hash = {}

############NOTE#################
# Change this value if necessary
################################
N = "1511840"

for eachLine in sys.stdin:
    eachLine = eachLine.strip()
    art_name = eachLine.split("\t")[0]
    category =  eachLine.split("\t")[1]

    if(art_hash.has_key(art_name)==False):
        art_hash[art_name]=[]

    art_hash[art_name].append(category)

for eachArt in art_hash.keys():
    categories = art_hash[eachArt]
    resultString = eachArt

    for eachCategory in categories:
        resultString += "\t" + eachCategory 


    print resultString+"\t"+str(len(categories))+"\t"+N
